-
Notifications
You must be signed in to change notification settings - Fork 519
Fix MethodExistsTypeSpecifyingExtension for union types #4150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.1.x
Are you sure you want to change the base?
Conversation
This pull request has been marked as ready for review. |
@liamduckett I just realized that the fix of this PR produces a false-positive (see the newly added testcase). just to let you know, as #4153 has the same problem |
if (!method_exists($bar, $method)) { | ||
throw new \Exception; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the we could build a better type in a TypeSpecifyingExtension
if the TypeSpecifierContext
would contain information, whether the context is always-terminating.
Thanks. I'm not sure I understand the new test case (probably due to my inexperience) - why would |
the initial types were wrongly narrowed:
while in the initial loop check example it is correct that $bar will have both methods at once:
|
closes phpstan/phpstan#13272